import json

from flask import Blueprint, request,jsonify
from models import *
import math

lx_bp = Blueprint("lx_bp",__name__)

@lx_bp.route('/getfy')
def fy():
    # 获取参数page
    page = int(request.args.get('page'))
    total = BjfyModel.query.count()
    # 定义每页显示多少条
    page_size = 3
    # 查询当前页记录
    start = math.ceil((page-1)*page_size)
    fy = BjfyModel.query.offset(start).limit(page_size).all()
    # fy = BjfyModel.query.all()
    print('=========',fy)
    list = [{
        "id":i.id,
        "name":i.name,
        "direction":i.direction
    }for i in fy]
    # return jsonify({'code':200,"flist":list})
    return jsonify({"code":200,"total":total,"page_size":page_size,"flist":list})